<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class charticle_ctr extends CI_Controller {  

	    function __construct()
    {
        parent::__construct();
 
		$this->load->library('grocery_CRUD');    
 
    }
	  
	public function index()
	{
		$this->load->model('charticle_mdl'); // load the file welcome_mdl.php
		//$rr['charticle'] = $this->charticle_mdl->get_all(); // call the method filtera inside the class welcome_mdl
		$rr['charticle'] = $this->charticle_mdl->get_all(); // call the method filtera inside the class welcome_mdl
		$this->load->view('charticle_vew',$rr);  // send the result from the model to the view 
	}
	
	public function method_go()
	{
		$this->load->view('go.php');  // show the view go ...	}
	
		public function get_fournisseurs_per_article()
    {
		
	$article_id = $_POST['record_id']; //set the record ID
    $this->load->model('my_custom_model');   //load the model file
	$this->my_custom_model->list_fourn_per_article($article_id); // create a query temporary table so crud can access and render it
    
	$crud = new grocery_CRUD();
		
	//	 $crud->set_theme('datatables');
    $crud->set_table('my_temp_table');
	$crud->set_primary_key('id_article', 'my_temp_table');
     
	$crud->unset_delete();
	$crud->unset_add();
	$crud->unset_edit();
	$crud->unset_read();
	 
	$crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'welcome/index');
	
	 
    //$crud->set_subject('conventions');
   // $crud->set_relation('id_chapitre','chapitres','nom_chapitre');
   // $crud->required_fields('id_convention_fk');
    // $crud->display_as('id_chapitre','nom');
   // $crud->fields('id_article','nom','solde','id_chapitres');
    $crud->columns('id_article','nom','solde','nom_chapitre');
	 $crud->display_as('id_article','id')->display_as('nom','االاسم')
 		  ->display_as('solde','الكمية')->display_as('nom_chapitre','الفقرة');

       // $crud->set_table('articles');
        $output = $crud->render();
 
        $this->load->view('list_fourn_per_article_vew',$output);
		$this->my_custom_model->clr_list_fourn_per_article();  //drop the "temporary table"
                 
    }
	
	public function pdf()
	{
     $this->load->helper(array('dompdf', 'file'));
     // page info here, db calls, etc.     
     $html = $this->load->view('go.php',NULL, true);
     pdf_create($html, 'filename');
     //or
     //$data = pdf_create($html, '', false);
     //write_file('name', $data);
     //if you want to write it to disk and/or send it as an attachment    
	}
	
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */